package com.zx.link.utils;

import java.util.List;

import com.zx.link.entity.Link;
import com.zx.link.entity.LinkType;

public class LinkToTreeGrid {

	public static String toJson(List<Link> linkList, List<LinkType> types){
		int total = linkList.size() + types.size();
		
		StringBuffer res = new StringBuffer();
		res.append("{\"total\":").append(total).append(",\"rows\":[");
		
		for (LinkType linkType : types) {
			res.append(linkType.toJSON()).append(",");
		}
		
		for (Link link : linkList) {
			res.append(link.toJSON()).append(",");
		}
		
		return res.toString().substring(0, res.length() -1) + "]}";
	}
	
}
